<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="js/axios-0.18.0.js"></script>
    <title>候选人票数</title>
    <style>
        table {
            border-collapse: collapse;
            width: 50%;
            margin: 20px auto;
        }
        th, td {
            border: 1px solid black;
            text-align: center;
            padding: 10px;
        }
        th {
            background-color: #f2f2f2;
        }
        h2{
            text-align: center;
        }
    </style>
</head>
<body>
<h2>候选人票数</h2>
<table>
    <tr>
        <th>候选人</th>
        <th>票数</th>
    </tr>
    <tr>
        <td>张三</td>
        <td id="1"></td>
    </tr>
    <tr>
        <td>李四</td>
        <td id="2"></td>
    </tr>
    <tr>
        <td>王五</td>
        <td id="3"></td>
    </tr>
    <tr>
        <td>赵六</td>
        <td id="4"></td>
    </tr>
</table>
<script>
    window.onload = function() {

        var requests = [
            axios.get('http://3245465132165.v5.idcfengye.com/users/17'),
            axios.get('http://3245465132165.v5.idcfengye.com/users/18'),
            axios.get('http://3245465132165.v5.idcfengye.com/users/19'),
            axios.get('http://3245465132165.v5.idcfengye.com/users/20')
        ];
        Promise.all(requests)
            .then(function (responses) {
                var responseData = responses.map(function (response) {
                    return response.data.data.gender;
                });

                for (var i = 0; i < responseData.length; i++) {
                    var cell = document.getElementById((i + 1).toString());
                    if (cell) {
                        cell.textContent = responseData[i];
                    }
                }
            })
    };
</script>
</body>
</html>